﻿/**
 * jQuery twiDropdown plugin 【下拉菜单】
 * @author: feitianxinhong  http://xuzhihong1987.blog.163.com/
 * @version 1.0
 * @create date:2013-10-29
 * @copyright (c) 2013 feitianxinhong/tyingsoft/twilight  http://www.tyingsoft.com
 * @example Visit 
 */

(function ($) {
    $.fn.twiDropdown = function (config) {
        config = $.extend({}, config);

        // Caching the jQuery object with all elements matched
        var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
        
        return this.each(function () {
            $(this).unbind('click').bind('click', function (e) {
                var id = $(this).attr('id');
                $("ul[to='" + id + "']").toggle();
                e.stopPropagation();
            });
        });
    }

    $(document).off('click.twi.dropdown').on('click.twi.dropdown', function () {
        $('.twiDropdownMenu').hide();
    });
})(jQuery);